home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / program / airvb25.zip / DELPHI.ZIP / UNIT1.PAS < prev   
Pascal/Delphi Source File  |  1995-12-10  |  3KB  |  104 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, VBXCtrl, Air25, ExtCtrls, StdCtrls, Menus;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Heading: TAir;
  12.     Airspeed: TAir;
  13.     Altimeter: TAir;
  14.     Climbrate: TAir;
  15.     HSI: TAir;
  16.     ADF: TAir;
  17.     RMI: TAir;
  18.     OBI: TAir;
  19.     Horizon: TAir;
  20.     Turn: TAir;
  21.     Label1: TLabel;
  22.     Timer1: TTimer;
  23.     MainMenu1: TMainMenu;
  24.     Exit1: TMenuItem;
  25.     Exit2: TMenuItem;
  26.     procedure Timer1Timer(Sender: TObject);
  27.     procedure FormCreate(Sender: TObject);
  28.     procedure Exit2Click(Sender: TObject);
  29.   private
  30.     { Private declarations }
  31.   public
  32.     { Public declarations }
  33.   end;
  34.  
  35. var
  36.   Form1: TForm1;
  37.  
  38. implementation
  39.  
  40. {$R *.DFM}
  41.  
  42. procedure TForm1.Timer1Timer(Sender: TObject);
  43. begin
  44.  
  45. {this is not a real simulation}
  46.     Horizon.Bank := Horizon.Bank + 2*Random(100)/100-1;
  47.     If Horizon.Bank > 30 Then Horizon.Bank := 30;
  48.     If Horizon.Bank < -30 Then Horizon.Bank := -30;
  49.  
  50.     Horizon.Pitch := Horizon.Pitch + 2*Random(100)/100-1;
  51.     If Horizon.Pitch > 30 Then Horizon.Pitch := 30;
  52.     If Horizon.Pitch < -30 Then Horizon.Pitch := -30;
  53.  
  54.     Climbrate.Value := 50 * Airspeed.Value * Sin(Horizon.Pitch * Cos(Horizon.Bank * 3.14159 / 180) * 3.14159 / 180);
  55.     Altimeter.Value := Altimeter.Value + Climbrate.Value / 100;
  56.  
  57.     Airspeed.Value := Airspeed.Value - Climbrate.Value / 2000;
  58.     If Airspeed.Value > 120 Then Airspeed.Value := 120;
  59.     If Airspeed.Value < 60 Then Airspeed.Value := 60;
  60.  
  61.     Heading.Value := Heading.Value - Airspeed.Value * Sin(Horizon.Bank * 3.14159 / 180) / 20;
  62.     OBI.OBICourse := Heading.Value;
  63.     ADF.ADFBearing := Heading.Value + 30;
  64.     RMI.RMIBearing := Heading.Value + 45;
  65.  
  66.     HSI.Value := Heading.Value;
  67.  
  68.     Turn.Turn := Airspeed.Value * Sin(Horizon.Bank * 3.14159 / 180) * Sin(Horizon.Pitch * 3.14159 / 180);
  69.  
  70.     {In this cockpit demo, all instruments have the AutoRedraw property
  71.     set to false for improved refresh rates.  This requires that
  72.     you force the instruments to redraw after all the instruments'
  73.     properties have been updated.  Setting the Redraw property to
  74.     True forces the instruments to be refreshed immediately. }
  75.  
  76.     Heading.Redraw := True;
  77.     Airspeed.Redraw := True;
  78.     Climbrate.Redraw := True;
  79.     Altimeter.Redraw := True;
  80.     HSI.Redraw := True;
  81.     Horizon.Redraw := True;
  82.     OBI.Redraw := True;
  83.     RMI.Redraw := True;
  84.     ADF.Redraw := True;
  85.  
  86. end;
  87. procedure TForm1.FormCreate(Sender: TObject);
  88. begin
  89.  
  90.      Randomize;
  91.      Altimeter.Value := 11250;
  92.      Airspeed.Value := 95;
  93.  
  94. end;
  95.  
  96. procedure TForm1.Exit2Click(Sender: TObject);
  97. begin
  98.  
  99.      Halt(0);
  100.  
  101. end;
  102.  
  103. end.
  104.